package net.heavencraft.bejeweled.jewel;

import java.util.EnumSet;
import java.util.Random;

/**
 * Represents the color of a jewel
 * 
 * @author Sven
 * 
 */
public enum JewelColor {

	REDSTONE("redstone.png", 3), DIAMOND("diamond.png", 4), IRON("iron.png", 1), GOLD(
			"gold.png", 2), EMERALD("emerald.png", 5);

	/**
	 * The name of the file that has the image of the Jewel
	 */
	private String name;

	/**
	 * The score value of this
	 */
	private int value;

	/**
	 * The color of a jewel
	 * 
	 * @param name
	 *            The filename of the Jewel
	 * @param value
	 *            The score-value of the Jewel
	 */
	JewelColor(String name, int value) {
		this.name = name;
		this.value = value;
	}

	/**
	 * Gets the filename of this jewel
	 * 
	 * @return The file name of this Jewel color
	 */
	public String getName() {
		return this.name;
	}

	/**
	 * Gets the value of this jewel
	 * 
	 * @return The value of this jewel
	 */
	public int getValue() {
		return this.value;
	}

	/**
	 * Gets a random JewelColor
	 * 
	 * @return A random generated JewelColor
	 */
	public static JewelColor getRandom() {
		EnumSet<JewelColor> colors = EnumSet.allOf(JewelColor.class);
		Random r = new Random();
		return colors.toArray(new JewelColor[0])[r.nextInt(colors.size())];
	}
}
